usbip: Fix potential format overflow in userspace tools
authorJonathan Dieter <jdieter@lesbg.com>
Mon, 27 Feb 2017 08:31:03 +0000 (10:31 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 19 Jun 2017 23:25:45 +0000 (00:25 +0100)
commit14ab009ef50f1c1c2a7a0e7b625ec27b4e40988f
treed935a49e54fa6d1f793659675b984b4d42b6a004
parentd92644a6e21e9c05d2b1d99d2a9fbc2afd246c61
usbip: Fix potential format overflow in userspace tools

The usbip userspace tools call sprintf()/snprintf() and don't check for
the return value which can lead the paths to overflow, truncating the
final file in the path.

More urgently, GCC 7 now warns that these aren't checked with
-Wformat-overflow, and with -Werror enabled in configure.ac, that makes
these tools unbuildable.

This patch fixes these problems by replacing sprintf() with snprintf() in
one place and adding checks for the return value of snprintf().

Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name usbip-Fix-potential-format-overflow-in-userspace-too.patch
tools/usb/usbip/libsrc/usbip_common.c
tools/usb/usbip/libsrc/usbip_host_common.c